<template>
	<view>
		<view style="margin-left: 200rpx;">当前积分价格：{{jf_money}}</view>
		<view style="margin-left: 200rpx;">兑换所需积分：{{buy_jf}}</view>
		<button @click="to_buy()" style="background-color: red; border-radius: 20px; color: #fff;margin-top: 20rpx;">立即兑换</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				buy_agent:1000,
				jf_money:0.002,
				buy_jf:0
			}
		},
		onShow(){
			var that=this;
			this.$myRequest({
				url: 'api/user/get_set_info',
				method:'POST',
			}).then(res=>{
					console.log(res)
					if(res.data.code==1){
						this.buy_agent=res.data.data.buy_agent;
						this.jf_money=res.data.data.jf_money;
						this.buy_jf=this.buy_agent/this.jf_money;
						this.buy_jf=this.buy_jf.toFixed(2);
					}
			})
		},
		methods: {
			to_buy(){
				var that=this;
				this.$myRequest({
					url: 'api/user/buy_agent',
					method:'POST',
				}).then(res=>{
						console.log(res)
						uni.showToast({
							title:res.data.msg,
							icon:'none'
						})
						if(res.data.code==1){
							uni.navigateBack();
						}
				})
			}
		}
	}
</script>

<style>

</style>
